//
//  VolunteerNovelController.m
//  HZHome
//
//  Created by Alawn on 13-10-13.
//  Copyright (c) 2013年 xzysun. All rights reserved.
//

#import "VolunteerNovelController.h"
#import "UIColor+expanded.h"
@interface VolunteerNovelController ()

@end

@implementation VolunteerNovelController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    if (self.config) {
        self.title=@"详细资料";
//        self.title=[self.config objectForKey:@"key"];
        _dataItem=[self.config objectForKey:@"dataItem"];
        self.txttitle.text=[CommonUtil dealNullObject:_dataItem.title];
        
        self.txtpresentation.text=[CommonUtil dealNullObject:_dataItem.presentation];
        self.txtcontent.text=[CommonUtil dealNullObject:_dataItem.content];
        self.txtaddress.text=[CommonUtil dealNullObject:_dataItem.address];
        self.txtdeadline.text=[CommonUtil dealNullObject:_dataItem.deadline];
        self.txtend_time.text=[CommonUtil dealNullObject:_dataItem.end_time];
        self.txtlinkman.text=[CommonUtil dealNullObject:_dataItem.linkman];
        
        self.txttitle.textColor=[UIColor colorWithHexString:@"005AB5"];
        self.labelJianJie.textColor=[UIColor colorWithHexString:@"005AB5"];
        self.labelNeiRong.textColor=[UIColor colorWithHexString:@"005AB5"];
    }
//    self.myscrollView.contentSize = CGSizeMake(320.0f, 800.0f);
    [self adjustViews];
}

-(void)adjustViews         
{
    CGFloat presentationHeight = [self caculateHeightForString:_txtpresentation.text AndFontSize:14.0 AndWitdh:CGRectGetWidth(_txtpresentation.frame)];
    NSLog(@"计算出简介的高度%f", presentationHeight);
    CGFloat contentHeight = [self caculateHeightForString:_txtcontent.text AndFontSize:14.0 AndWitdh:CGRectGetWidth(_txtcontent.frame)];
    NSLog(@"计算出内容的高度%f", contentHeight);
    //调整简介高度
    CGRect presentationFrame = _txtpresentation.frame;
    presentationFrame.size.height = presentationHeight;
    _txtpresentation.frame = presentationFrame;
    //调整内容标题
    CGRect contentTitleFrame = _contentTitleLabel.frame;
    contentTitleFrame.origin.y = CGRectGetMaxY(_txtpresentation.frame) + 8.0;
    _contentTitleLabel.frame = contentTitleFrame;
    //调整分割线
    CGRect contentLineFrame = _contentLine.frame;
    contentLineFrame.origin.y = CGRectGetMaxY(_contentTitleLabel.frame) + 8.0;
    _contentLine.frame = contentLineFrame;
    //调整内容框
    CGRect contentFrame = _txtcontent.frame;
    contentFrame.origin.y = CGRectGetMaxY(_contentLine.frame) + 8.0;
    contentFrame.size.height = contentHeight;
    _txtcontent.frame = contentFrame;
    //底下的那堆东西
    [_myscrollView addSubview:_additionalPanel];
    _additionalPanel.frame = CGRectMake(0, CGRectGetMaxY(_txtcontent.frame) + 8.0, 320.0, CGRectGetHeight(_additionalPanel.frame));
    _myscrollView.contentSize = CGSizeMake(320.0, CGRectGetMaxY(_additionalPanel.frame));
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(IBAction)CallPhone:(id)sender
{
    NSString* numberAfterClear =self.btnphone.titleLabel.text;
    NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", numberAfterClear]];
    NSLog(@"make call, URL=%@", phoneNumberURL);
    [[UIApplication sharedApplication] openURL:phoneNumberURL];
}

- (void)didFinishLaunchingWithOptions{
    [self installUncaughtExceptionHandler];
}
//捕捉异常
- (void)installUncaughtExceptionHandler{
//	InstallUncaughtExceptionHandler();
}
@end
